#!/usr/bin/env node

const log = console.log,
      file = process.argv[2],
      fs = require('fs');

if(process.argv.length !== 3){
  console.error('命令行参数格式：cmd file_name');
  process.exit(1);
}

let buf;

try{
  buf = fs.readFileSync(file);
}catch(e){
  console.error(e.message);
  process.exit(2);
}

if(buf.toString('ascii',0,2) === 'BM'){
  log('width:',buf.readInt32LE(0x12));
  log('height:',buf.readInt32LE(0x16));
  log('color depth:',buf.readUInt16LE(0x1c));
}
